var path = require('path');
var webpack = require('webpack');
var HtmlwebpackPlugin = require('html-webpack-plugin');

var ROOT_PATH = path.resolve(__dirname);
var APP_PATH = path.resolve(ROOT_PATH, 'app');
var BUILD_PATH = path.resolve(ROOT_PATH, 'build');

module.exports= {
  entry: {
    app: path.resolve(APP_PATH, 'app.jsx')
  },
  output: {
    path: BUILD_PATH,
    filename: 'bundle.js'
  },
  //enable dev source map
  devtool: 'eval-source-map',
  //enable dev server
  devServer: {
    historyApiFallback: true,
    hot: true,
    inline: true,
    progress: true
  },
  resolve: {
    extensions: ['', '.js', '.jsx'],
    root: APP_PATH
  },
  module: {
    // preLoaders: [
    //   {
    //     test: /\.jsx?$/,
    //     loaders: ['eslint'],
    //     include: APP_PATH
    //   }
    // ],
    loaders: [
      {
        test: /\.jsx?$/,
        exclude: /node_modules/,
        //loaders: ['babel'],
        //include: APP_PATH,
        loaders: ['babel', 'babel?presets[]=es2015,presets[]=react,plugins[]=transform-object-rest-spread']
      },
      {
        test: /\.scss$/,
        loaders: ['style', 'css', 'sass']
      },
      {
　　　　　test: /\.(png|jpg)$/,
　　　　　loader: 'url-loader?limit=8192&name=images/[hash:8].[name].[ext]'
　　　 },
      {
        test:/\.(eot|ttf|woff|woff2|svg)$/,
        loader:'file?name=fonts/[name].[ext]'
      }
    ]
  },
  plugins: [
    new HtmlwebpackPlugin({
      title: '国学圆桌',
      template: 'my-index.html',
      inject: true,
      hash: true
    })
  ]
}
